import request from '@/config/axios'

// 通知 VO
export interface PublishStuffVO {
  title: string // 标题
  content: string // 模板内容
  attachment: string // 附件URL 多个用逗号隔开
  receiverClassInfo: string // 接收班级信息
  receiverStudentInfo: string // 接收学生信息
  timing: string // 发布时机（immediately：立即通知 fixed-time：定时通知）
  cron: string // 时间cron表达式,定时通知时必填
}

// 通知 API
export const PublishStuffApi = {
  // 查询通知分页
  getPublishStuffPage: async (params: any) => {
    return await request.get({ url: `/system/publish-stuff/page`, params })
  },

  // 查询通知详情
  getPublishStuff: async (id: number) => {
    return await request.get({ url: `/system/publish-stuff/get?id=` + id })
  },

  // 新增通知
  createPublishStuff: async (data: PublishStuffVO) => {
    return await request.post({ url: `/system/publish-stuff/create`, data })
  },

  // 修改通知
  updatePublishStuff: async (data: PublishStuffVO) => {
    return await request.put({ url: `/system/publish-stuff/update`, data })
  },

  // 删除通知
  deletePublishStuff: async (id: number) => {
    return await request.delete({ url: `/system/publish-stuff/delete?id=` + id })
  },

  // 导出通知 Excel
  exportPublishStuff: async (params) => {
    return await request.download({ url: `/system/publish-stuff/export-excel`, params })
  }
}